previewLabApplication
fun previewLabApplication(previewList: List<PreviewLabPreview>, featuredFileList: Map<String, List<String>> = emptyMap(), openFileHandler: OpenFileHandler<out Any?>? = null, state: PreviewLabGalleryState = PreviewLabGalleryState(), rootElement: HTMLElement = document.body!!)
Launches a WebAssembly application for previewing Compose components
Creates a high-performance browser-based interface using Compose for WebAssembly. Provides near-native performance for interactive component development and testing in web environments. Supports the same features as the standard web version with improved execution speed and memory efficiency.
// Basic WASM application
fun main() = previewLabApplication(
previewList = myModule.PreviewList
)
// With file handler integration
fun main() = previewLabApplication(
previewList = myModule.PreviewList,
openFileHandler = UrlOpenFileHandler("https://github.com/user/repo/blob/main"),
featuredFileList = mapOf(
"UI Components" to listOf("Button.kt", "TextField.kt"),
"Navigation" to listOf("TopBar.kt", "Drawer.kt")
)
)
// Performance-optimized setup
fun main() {
val container = document.getElementById("preview-app") as HTMLElement
previewLabApplication(
previewList = myModule.PreviewList,
rootElement = container
)
}Content copied to clipboard
Parameters
previewList
Collection of previews to display in the interface
featuredFileList
Grouped file organization for navigation
openFileHandler
Handler for opening source files (optional)
state
PreviewLabGalleryState for managing gallery state
rootElement
HTML element to mount the application (defaults to document.body)